package com.wjj.orderservice.controller;


import com.wjj.orderservice.common.CommonResult;
import com.wjj.orderservice.domain.PurchaseOrder;
import com.wjj.orderservice.service.IPurchaseOrderService;
import jdk.nashorn.internal.runtime.linker.LinkerCallSite;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器   (采购订单)
 * </p>
 *
 * @author wjj
 * @since 2021-12-15
 */
@RestController
@RequestMapping("/purchaseOrder")
public class PurchaseOrderController {

    @Autowired
    private IPurchaseOrderService purchaseOrderService;


    // TODO: 添加采购订单
    @RequestMapping("")
    public CommonResult savePurchaseOrder(@RequestBody PurchaseOrder purchaseOrder){

        boolean b = purchaseOrderService.saveOrUpdate(purchaseOrder);

        if(b){
            System.out.println("保存成功！！！");
            return CommonResult.success(b,"保存成功！！！");
        }
            System.out.println("保存失败！！！");

        return CommonResult.success("保存失败！！！");
    }


    //查询我订单所有的字段
    @RequestMapping("selectOrderField")
    public CommonResult selectOrderField(){
        List<PurchaseOrder> list = purchaseOrderService.list();

        return CommonResult.success(list,"查询采购订单表的所有的字段!!!");
    }

}

